﻿--[[
    @brief   more_zone_tips_control
    @author  farleywen
    @version 1.0
    @date    2015/12/09
--]]

more_zone_tips_control = 
{
    init = function()
        base_utility.log("[more_zone_tips_control] init");
        
        ierd_tgp.tpf_ui.Require("more_zone_tips\\model.lua");
        ierd_tgp.tpf_ui.Require("more_zone_tips\\view.lua");
    end;
                
    set_tips = function(game_id, content) 
        base_utility.log("[more_zone_tips_control] set_tips"); 
        more_zone_tips_model.game_id = game_id;
        if content ~= nil then
            more_zone_tips_model.content = content;
        end
    end;
    
    on_close_interval = function(time_stamp)
        base_utility.log("[more_zone_tips_control] on_close_interval time_stamp="..time_stamp);
        local tpfui =
            base_utility.get_component_adapter("ITpf_ui",
                "ierd_tgp.tpf_ui.GetTPFUI();");
        tpfui:RemoveInterval('more_zone_tips_control.on_close_interval');
        more_zone_tips_view.close();
    end
};

function more_zone_tips_control:on_show(game_id, content)
    base_utility.log("[more_zone_tips_control] on_show");   
    more_zone_tips_control.set_tips(game_id, content);
    more_zone_tips_view.show();
end;

function more_zone_tips_control:on_show_morezone_tip(event_id, json_str)
    local param = base_utility.json_to_table(json_str);
    local game_id = param["game_id"];
    if game_id == nil then
        return;
    end;
    local game_lib =
        base_utility.get_component_adapter("IGame_library",
            "ierd_tgp.game_library.Get_game_library_adapter();");
    if game_lib == nil then
        return;
    end;
    local game_info = ierd_tgp.game_library.GameDetailInfo:new();
    game_lib:get_game_detail_info(game_id, game_info);
    -- local content = game_info.name.."支持同帐号登录多个区服，点击尝试";
    local content = LoadStr("MORE_ZONE_SUPPORT");
    game_info:delete();
    more_zone_tips_control.set_tips(game_id, content);
    more_zone_tips_view.show();
    more_zone_tips_control:on_timeout();
end;

function more_zone_tips_control:close()
    base_utility.log("[more_zone_tips_control] close");   
    more_zone_tips_view.close();
end;

function more_zone_tips_control:on_timeout()
    base_utility.log("[more_zone_tips_control] set_timeout");   
    local tpfui =
        base_utility.get_component_adapter("ITpf_ui",
            "ierd_tgp.tpf_ui.GetTPFUI();");
    tpfui:AddInterval('more_zone_tips_control.on_close_interval', more_zone_tips_model.timeout);
end;

more_zone_tips_control.init();